******************************************************************
***   Programmer: C. Deal                             
***   Date Created: March 6, 2024
***   Replication File for Deal, Doshi, and Gonzales (2023) JAH
******************************************************************

*Change global path to command directory of replication files
global path "C:\Users\cdeal\Box\New Box Folder for RAs\Cameron Deal\Completed Projects\Gender Minorities & Homelessness\replication"

cd "$path"

*Open your data for analysis
use "$path\2017_2019_yrbs_states", clear

***Primary Grouping Variables

*Homelessness Binary
destring qwheresleep, generate(homelessnum)
gen homelessbin=.
replace homelessbin = 0 if homelessnum==1
replace homelessbin = 1 if homelessnum>=2 & homelessnum<=7
label define homelessbin_label 0 "Not Homeless" 1 "Homeless"
label values homelessbin homelessbin_label
label var homelessbin "Homelessness"
tab homelessbin

*Sexual Orientation Categories
destring q66, generate(sexualitynum)
gen sexualitycat=.
replace sexualitycat = 1 if sexualitynum==1 & sexpart2==1
replace sexualitycat = 1 if sexualitynum==1 & sexpart2==2
replace sexualitycat = 2 if sexualitynum==2 
replace sexualitycat = 3 if sexualitynum==3
replace sexualitycat = 4 if sexualitynum==4  
replace sexualitycat = 5 if sexpart2==3 & sexualitynum==1
label define sexualitycat_label 1 "Heterosexual" 2 "Lesbian or Gay" 3 "Bisexual" 4 "Unsure" 5 "Heterosexual with Same-Sex Partners"
label values sexualitycat sexualitycat_label
label var sexualitycat "Sexual Orientation Categories"
tab sexualitycat

*Gender Minority Binary 
gen genderbin = .
replace genderbin = 1 if qntransgender==1 | qtransgender=="3"
replace genderbin = 0 if qtransgender=="1" 
label define genderbin 0 "Cisgender" 1 "Gender Minority"
label values genderbin genderbin
label var genderbin "Gender Minority Status"
tab genderbin

*Transgender categories 
gen gendercat = .
replace gendercat = 1 if qtransgender=="1"
replace gendercat = 2 if qtransgender=="2"
replace gendercat = 3 if qtransgender=="3"
label define gendercat 1 "Cisgender" 2 "Transgender" 3 "Gender Questioning"
label values gendercat gendercat
label var gendercat "Gender Minority Status"
tab gendercat

*Strictly Transgender
gen transgender = .
replace transgender = 1 if qntransgender==1
replace transgender = 0 if qtransgender=="1"
label define transgender 0 "Cisgender" 1 "Transgender" 
label values transgender transgender
label var transgender "Transgender Status"
tab transgender

*Strictly Gender questioning
gen genderquest = .
replace genderquest = 1 if qtransgender=="3"
replace genderquest = 0 if qtransgender=="1" 
label define genderquest 0 "Non Gender Questioning" 1 "Gender Questioning" 
label values genderquest genderquest
label var genderquest "Gender Questioning Status"
tab genderquest

*Comparing Transgender with Gender Questioning
gen genmin_compare = .
replace genmin_compare = 1 if qtransgender=="3"
replace genmin_compare = 0 if qntransgender==1 
label define genmin_compare 0 "Transgender" 1 "Gender Questioning" 
label values genmin_compare genmin_compare
label var genmin_compare "Comparing Transgender with Gender Questioning"
tab genmin_compare

*Sexuality Binary (LGBT+ or not)
gen sexualitybin = .
replace sexualitybin = 0 if sexualitynum==1  
replace sexualitybin = 1 if sexpart2==3 & sexualitynum==1
replace sexualitybin = 1 if sexualitynum>=2 & sexualitynum<=4
label define sexualitybin_label 0 "Heterosexual" 1 "LGBT+"
label values sexualitybin sexualitybin_label
label var sexualitybin "LGBT+ or Not"
tab sexualitybin

*Sex
gen male = 0
replace male = 1 if sex==2

gen female = 0
replace female = 1 if sex==1

*Year
gen year_factor=.
replace year_factor = 0 if year==2017
replace year_factor = 1 if year==2019
tab year_factor

*Transgender Categories- unable to differentiate further because can't determine whether answers to sex question represent sex assigned at birth or gender identity

*Age Categories
gen agecat1 = .
replace agecat1 = 1 if age>=1 & age<=3
replace agecat1 = 2 if age>=4 & age<=5
replace agecat1 = 3 if age>=6 & age<=7
label define agecat1 1 "12 and under to 14" 2 "15 to 16" 3 "17 to 18 and older" 
label values agecat1 agecat1
label var agecat1 "Age Categories"
tab agecat1

*Grade Level is already found in the original dataset as grade

*Race is already found in the original dataset as race4

*Homelessness Categories 1- for comparison to broader non-homeless population
gen homelesscat=.
replace homelesscat = 1 if homelessnum==1
replace homelesscat = 2 if homelessnum==2
replace homelesscat = 3 if homelessnum==3
replace homelesscat = 4 if homelessnum==4
replace homelesscat = 5 if homelessnum>=5 & homelessnum<=6
replace homelesscat = 6 if homelessnum==7
label define homelesscat_label 1 "Not Homeless" 2 "Non-Parental Home" 3 "Shelter" 4 "Hotel" 5 "Streets" 6 "Other"
label values homelesscat homelesscat_label
label var homelesscat "Homelessness Categories"
tab homelesscat

*Homelessness Categories 2- for comparison within non-homeless population
gen homelesscat2=.
replace homelesscat2 = 2 if homelessnum==2
replace homelesscat2 = 3 if homelessnum==3
replace homelesscat2 = 4 if homelessnum==4
replace homelesscat2 = 5 if homelessnum>=5 & homelessnum<=6
replace homelesscat2 = 6 if homelessnum==7
label define homelesscat2 2 "Non-Parental Home" 3 "Shelter" 4 "Hotel" 5 "Streets" 6 "Other"
label values homelesscat2 homelesscat2
label var homelesscat2 "Homelessness Categories"
tab homelesscat2

*Destring sitename
encode sitename, gen(sitename_factor)
tab sitename_factor

**Types of Homelessness Dummy Variables
*Non-Parental Home
gen non_parental=.
replace non_parental = 0 if homelessbin==1 & homelessnum!=2
replace non_parental = 1 if homelessnum==2
tab non_parental

*Shelter
gen shelter=.
replace shelter = 0 if homelessbin==1 & homelessnum!=3
replace shelter = 1 if homelessnum==3
tab shelter

*Hotel
gen hotel_homeless=.
replace hotel_homeless = 0 if homelessbin==1 & homelessnum!=4
replace hotel_homeless = 1 if homelessnum==4
tab hotel_homeless

*Streets
gen streets=.
replace streets = 0 if homelessbin==1 & homelesscat!=5
replace streets = 1 if homelesscat==5
tab streets

*Other
gen other_homeless=.
replace other_homeless = 0 if homelessbin==1 & homelesscat!=6
replace other_homeless = 1 if homelesscat==6
tab other_homeless


*Policy Friendliness- These scores were compiled by the Movement Advancement Project (https://www.lgbtmap.org/equality-maps) and reflect the overall friendliness of state policies toward LGBTQ populations
gen policy_score=.
replace policy_score = 18.25 if sitename== "Colorado (CO)"
replace policy_score = 12.75 if sitename== "Delaware (DE)"
replace policy_score = 4.50 if sitename== "Florida (FL)"
replace policy_score = 16.50 if sitename== "Hawaii (HI)"
replace policy_score = 17.50 if sitename== "Maine (ME)"
replace policy_score = 14.50 if sitename== "Maryland (MD)"
replace policy_score = 7.00 if sitename== "Michigan (MI)"
replace policy_score = 19.0 if sitename== "Nevada (NV)"
replace policy_score = 17.50 if sitename== "New Jersey (NJ)"
replace policy_score = 17.25 if sitename== "New York (NY)"
replace policy_score = 9.25 if sitename== "Pennsylvania (PA)"
replace policy_score = 17.00 if sitename== "Rhode Island (RI)"
replace policy_score = 17.50 if sitename== "Vermont (VT)"
replace policy_score = 13.00 if sitename== "Virginia (VA)"
replace policy_score = 4.50 if sitename== "Wisconsin (WI)"
label var policy_score "Transgender-Friendly Policy Score"
tab policy_score

*Stigma1- Measured by percentage favoring LGBT acceptance- These values were taken from the Pew Research Center's Religious Landscape Study, which measured the percent of a state that said homosexuality should be accepted (https://www.pewresearch.org/religion/religious-landscape-study/)
gen stigma_percent1=.
replace stigma_percent1 = 67 if sitename== "Colorado (CO)"
replace stigma_percent1 = 67 if sitename== "Delaware (DE)"
replace stigma_percent1 = 64 if sitename== "Florida (FL)"
replace stigma_percent1 = 64 if sitename== "Hawaii (HI)"
replace stigma_percent1 = 69 if sitename== "Maine (ME)"
replace stigma_percent1 = 66 if sitename== "Maryland (MD)"
replace stigma_percent1 = 62 if sitename== "Michigan (MI)"
replace stigma_percent1 = 69 if sitename== "Nevada (NV)"
replace stigma_percent1 = 71 if sitename== "New Jersey (NJ)"
replace stigma_percent1 = 70 if sitename== "New York (NY)"
replace stigma_percent1 = 63 if sitename== "Pennsylvania (PA)"
replace stigma_percent1 = 72 if sitename== "Rhode Island (RI)"
replace stigma_percent1 = 79 if sitename== "Vermont (VT)"
replace stigma_percent1 = 61 if sitename== "Virginia (VA)"
replace stigma_percent1 = 66 if sitename== "Wisconsin (WI)"
label var stigma_percent1 "LGBT Acceptance"
tab stigma_percent1

***Health Outcomes

**Mental Health

*Considered Suicide
gen considered_suicide=.
replace considered_suicide = 1 if q26=="1"
replace considered_suicide = 0 if q26=="2"
tab considered_suicide

*Attempted Suicide
gen attempted_suicide=.
replace attempted_suicide = 1 if qn28==1
replace attempted_suicide = 0 if qn28==2
tab attempted_suicide

*Planned Suicide
gen planned_suicide=.
replace planned_suicide = 1 if q27=="1"
replace planned_suicide = 0 if q27=="2"
tab planned_suicide

*Sad or Hopeless
gen sad_hopeless=.
replace sad_hopeless = 1 if q25=="1"
replace sad_hopeless = 0 if q25=="2"
tab sad_hopeless

*Suicide attempt that required medical treatment
gen suicide_treatment=.
replace suicide_treatment = 1 if qn29==1
replace suicide_treatment = 0 if qn29==2
tab suicide_treatment



*Suicidal Activities Binary
gen suicide_bin=.
replace suicide_bin = 1 if considered_suicide==1 | attempted_suicide==1 | planned_suicide==1
replace suicide_bin = 0 if considered_suicide==0 & attempted_suicide==0 & planned_suicide==0
tab suicide_bin

**Aggression

*Physical Fight
gen fight=.
replace fight = 1 if qn17==1
replace fight = 0 if qn17==2
tab fight

*Carried a Weapon
gen weapon=.
replace weapon = 1 if qn12==1
replace weapon = 0 if qn12==2
tab weapon



**Risky Sex Behaviors

*Sexually Active
gen sex_active=.
replace sex_active = 1 if qn61==1
replace sex_active = 0 if qn61==2
tab sex_active 

*Had sex with 4 or more partners
gen sex_4=.
replace sex_4 = 1 if qn60==1
replace sex_4 = 0 if qn60==2
tab sex_4

*Substances before sex
gen substance_sex=.
replace substance_sex = 1 if qn62==1
replace substance_sex = 0 if qn62==2
tab substance_sex

*Unprotected sex
gen unprotected_sex=.
replace unprotected_sex = 1 if q64=="2"
replace unprotected_sex = 0 if q64=="1" | q64=="3" | q64=="4" | q64=="5" | q64=="6" | q64=="7" | q64=="8" 
tab unprotected_sex




**Substance Use

*Cigarette smoking
gen cigarette=.
replace cigarette = 1 if q30=="1"
replace cigarette = 0 if q30=="2"
tab cigarette

*Alcohol Use
gen alcohol=.
replace alcohol = 1 if qn41==1
replace alcohol = 0 if qn41==2
tab alcohol

*Binge Drinking
gen binge_drinking=.
replace binge_drinking = 1 if qn42==1
replace binge_drinking = 0 if qn42==2
tab binge_drinking

*Marijuana
gen marijuana=.
replace marijuana = 1 if qn47==1
replace marijuana = 0 if qn47==2
tab marijuana

*Cocaine
gen cocaine=.
replace cocaine = 1 if qn50==1
replace cocaine = 0 if qn50==2
tab cocaine

*Smokeless Tobacco
gen no_smoke_tobacco=.
replace no_smoke_tobacco = 1 if qn37==1
replace no_smoke_tobacco = 0 if qn37==2
tab no_smoke_tobacco

*Cigarillos, Cigars, etc.
gen alt_smoking=.
replace alt_smoking = 1 if qn38==1
replace alt_smoking = 0 if qn38==2
tab alt_smoking

*Vaping
gen vape=.
replace vape = 1 if qn35==1
replace vape = 0 if qn35==2
tab vape


*Tobacco Binary
gen tobacco_bin=.
replace tobacco_bin = 1 if qntb4==1 
replace tobacco_bin = 0 if qntb4==2
tab tobacco_bin

*Alcohol Binary- already coded as alcohol

*Other variables surrounding substance use (methamphetamines, heroin, unprescribed drugs) weren't asked in all of the sampled states and had small sample sizes



*****************************************
*** Identify Sample
*****************************************
*Adjust weights for pooled estimation (divide by the number of years w/ gender minority and homelessness recorded)
gen weight_sample=.
replace weight_sample=weight if sitename!="Hawaii (HI)"
replace weight_sample=(weight/2) if sitename=="Hawaii (HI)" /*HI is the only state that records both homelessness and gender minority status in 2017 and 2019*/

*Tell Stata you are using survey weights
svyset psu [pweight=weight_sample], strata(stratum)
set more off, perm

* Alternate method- best delineation between inclusion in study and non-inclusion
gen included1=0
replace included1 = 1 if homelessnum!=. & qntransgender!=.
label define included1_label 0 "Not Included" 1 "Included"
label values included1 included1_label
label var included1 "Included in Study"
tab included1



***************************************************************************
***********   			     ANALYSIS    			     ******************
***************************************************************************
*Descriptive Statistics with `tabout' command

global covariates "i.agecat1 i.race4 i.sex i.sitename_factor i.year_factor"
global covariates_nostates "i.agecat1 i.race4 i.sex"
global covariates_sexuality "i.agecat1 i.race4 i.sex i.sitename_factor i.year_factor i.sexualitycat"

*Raw sample sizes
tab genderbin if included1==1

*Weighted Estimates
svy, subpop(if included1==1 & genderbin==1): tab homelessbin, col
svy, subpop(if included1==1 & genderbin==0): tab homelessbin, col

*Proper Prevalence
svy: tabulate genderbin homelessbin, count format(%14.3gc)

log using results.smcl, replace
*Establishing Homelessness Disparity:
*uncontrolled disparity
svy, subpop(if included1==1): logit homelessbin i.genderbin
margins, dydx(genderbin) vce(unconditional) subpop(if included1==1)
*adding controls disparity
svy, subpop(if included1==1): logit homelessbin $covariates i.genderbin
margins, dydx(genderbin) vce(unconditional) subpop(if included1==1)
log close

**Final Analyses*******************************************************************************************************************************************************


*****************************************************************
* Table 1: Descriptives by Homeless and Gender Minority Statuses
*****************************************************************
*Differences across homeless status within gender minorities
tabout genderbin homelessbin using descriptives_trans.xls if included1==1, svy cell(row se) stats(chi2) nlab(count) f(4) sebnone replace
foreach var in agecat1 grade race4 sex homelesscat {
tabout `var' homelessbin using descriptives_trans.xls if included1==1 & genderbin==1, svy cell(col se) stats(chi2) nlab(count) f(4) sebnone append
}
*Differences across homeless status within cisgender
tabout genderbin homelessbin using descriptives_cis.xls if included1==1, svy cell(row se) stats(chi2) nlab(count) f(4) sebnone replace
foreach var in agecat1 grade race4 sex homelesscat {
tabout `var' homelessbin using descriptives_cis.xls if included1==1 & genderbin==0, svy cell(col se) stats(chi2) nlab(count) f(4) sebnone append
}


*****************************************************************
* Figure 2: Types of Homelessness and significant differences
*****************************************************************
log using results.smcl, append
*Means for each type of homelessness
foreach var in non_parental shelter streets hotel_homeless other_homeless {
svy, subpop(if included1==1): mean `var' if homelesscat!=1, over(genderbin)
}
*Test significance for differences
foreach var in non_parental shelter streets hotel_homeless other_homeless {
svy, subpop(if included1==1): logit `var' i.genderbin $covariates
margins, dydx(genderbin) vce(unconditional) subpop(if included1==1)
}

*****************************************************************
* Table 2: Health Prevalences and Marginal Effects by Homelessness/Gender Minority
*****************************************************************
**Gender Minority Homeless vs. Gender Minority Non-Homeless
log close
*Prevalences
tabout genderbin homelessbin using healthprevalences_trans.xls if included1==1, svy cell(row se) stats(chi2) nlab(count) f(4) sebnone replace
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
tabout `var' homelessbin using healthprevalences_trans.xls if included1==1 & genderbin==1, svy cell(col se) stats(chi2) nlab(count) f(4) sebnone append
}
log using results.smcl, append
*Marginal Effects
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
svy, subpop(if included1==1 & genderbin==1): logit `var' i.homelessbin $covariates
margins, dydx(homelessbin) vce(unconditional) subpop(if included1==1 & genderbin==1)
}
log close

**Cisgender Homeless vs. Cisgender Non-Homeless
*Prevalences
tabout genderbin homelessbin using healthprevalences_cis.xls if included1==1, svy cell(row se) stats(chi2) nlab(count) f(4) sebnone replace
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
tabout `var' homelessbin using healthprevalences_cis.xls if included1==1 & genderbin==0, svy cell(col se) stats(chi2) nlab(count) f(4) sebnone append
}
log using results.smcl, append
*Marginal Effects
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
svy, subpop(if included1==1 & genderbin==0): logit `var' i.homelessbin $covariates
margins, dydx(homelessbin) vce(unconditional) subpop(if included1==1 & genderbin==0)
}
log close

**Gender Minority Homeless vs. Cisgender Homeless
*Prevalences (Redundant)
tabout genderbin homelessbin using healthprevalences_homeless.xls if included1==1, svy cell(row se) stats(chi2) nlab(count) f(4) sebnone replace
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
tabout `var' genderbin using healthprevalences_homeless.xls if included1==1 & homelessbin==1, svy cell(col se) stats(chi2) nlab(count) f(4) sebnone append
}
log using results.smcl, append
*Marginal Effects
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
svy, subpop(if included1==1 & homelessbin==1): logit `var' i.genderbin $covariates
margins, dydx(genderbin) vce(unconditional) subpop(if included1==1 & homelessbin==1)
}
log close

*****************************************************************
* Appendix Table 1: Descriptives within homeless across gender minority
*****************************************************************
*differences across homeless status within cisgender
tabout genderbin homelessbin using appendix_characteristics.xls if included1==1, svy cell(row se) stats(chi2) nlab(count) f(4) sebnone replace
foreach var in agecat1 grade race4 sex homelesscat {
tabout `var' genderbin using appendix_characteristics.xls if included1==1 & homelessbin==1, svy cell(col se) stats(chi2) nlab(count) f(4) sebnone append
}


log using results.smcl, append
*****************************************************************
* Appendix Table 2: Differences when comparing gender minority to only cisgender heterosexual individuals
*****************************************************************
*Comparison variable- Gender Minorities are coded as 1
gen cishet_v_gendermin=.
replace cishet_v_gendermin=1 if genderbin==1
replace cishet_v_gendermin=0 if sexualitybin==0 & genderbin==0

*Replicate Initial Homelessness Disparity:
*uncontrolled disparity
svy, subpop(if included1==1): logit homelessbin i.cishet_v_gendermin
margins, dydx(cishet_v_gendermin) vce(unconditional) subpop(if included1==1)
*adding controls disparity
svy, subpop(if included1==1): logit homelessbin $covariates i.cishet_v_gendermin
margins, dydx(cishet_v_gendermin) vce(unconditional) subpop(if included1==1)

*Apply to replicate Table 2:
**Gender Minority Homeless vs. Gender Minority Non-Homeless
log close
*Prevalences
tabout cishet_v_gendermin homelessbin using appendix_healthprevalences_trans.xls if included1==1, svy cell(row se) stats(chi2) nlab(count) f(4) sebnone replace
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
tabout `var' homelessbin using appendix_healthprevalences_trans.xls if included1==1 & cishet_v_gendermin==1, svy cell(col se) stats(chi2) nlab(count) f(4) sebnone append
}
log using results.smcl, append
*Marginal Effects
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
svy, subpop(if included1==1 & cishet_v_gendermin==1): logit `var' i.homelessbin $covariates
margins, dydx(homelessbin) vce(unconditional) subpop(if included1==1 & cishet_v_gendermin==1)
}
log close

**Cisgender Homeless vs. Cisgender Non-Homeless
*Prevalences
tabout cishet_v_gendermin homelessbin using appendix_healthprevalences_cis.xls if included1==1, svy cell(row se) stats(chi2) nlab(count) f(4) sebnone replace
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
tabout `var' homelessbin using appendix_healthprevalences_cis.xls if included1==1 & cishet_v_gendermin==0, svy cell(col se) stats(chi2) nlab(count) f(4) sebnone append
}
log using results.smcl, append
*Marginal Effects
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
svy, subpop(if included1==1 & cishet_v_gendermin==0): logit `var' i.homelessbin $covariates
margins, dydx(homelessbin) vce(unconditional) subpop(if included1==1 & cishet_v_gendermin==0)
}
log close

**Gender Minority Homeless vs. Cisgender Homeless
*Prevalences (Redundant)
tabout cishet_v_gendermin homelessbin using appendix_healthprevalences_homeless.xls if included1==1, svy cell(row se) stats(chi2) nlab(count) f(4) sebnone replace
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
tabout `var' cishet_v_gendermin using appendix_healthprevalences_homeless.xls if included1==1 & homelessbin==1, svy cell(col se) stats(chi2) nlab(count) f(4) sebnone append
}
log using results.smcl, append
*Marginal Effects
foreach var in considered_suicide planned_suicide attempted_suicide suicide_treatment sad_hopeless sex_4 sex_active unprotected_sex substance_sex alcohol binge_drinking tobacco_bin marijuana cocaine {
svy, subpop(if included1==1 & homelessbin==1): logit `var' i.cishet_v_gendermin $covariates
margins, dydx(cishet_v_gendermin) vce(unconditional) subpop(if included1==1 & homelessbin==1)
}
log close






